﻿using Bll;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model;

namespace Denglu.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class LoginCroller : ControllerBase
    {
        private readonly adminBll bll;

        public LoginCroller(adminBll bll)
        {
            this.bll = bll;
        }

        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult PostRegister(T_Admin info)
        {
            try
            {
                int res = bll.PostRegister(info);
                return Ok(new
                {
                    data = res
                });
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="name"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetLogin(string name, string pwd)
        {
            try
            {
                var list = bll.GetLogin(name, pwd);
                return Ok(new
                {
                    data = list
                });
            }
            catch (Exception)
            {
                throw;
            }
        }
    }
}
